package main

import "fmt"

// panic和recover：https://blog.csdn.net/qq522044637/article/details/125394515
// panic触发流程
func main() {
	defer fmt.Println("main---1---")
	defer fmt.Println("main---2---")
	fmt.Println("main---3---")
	mytest(1)
	defer fmt.Println("main---4---")
	fmt.Println("main---5---")
}

func mytest(num int) {
	defer fmt.Println("mytest---1---")
	defer fmt.Println("mytest---2---")
	fmt.Println("mytest---3---")
	if num == 1 {
		panic("出现异常，抛出panic")
	}
	defer fmt.Println("mytest---4---")
	fmt.Println("mytest---5---")
}
